package org.gorson.function;


import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;
import org.gorson.BO.AssetDetailBO;
import org.gorson.BO.OdsRepayPlanBO;
import org.gorson.utils.CastUtil;

public class ProcessCmbToAssetDetailFunction extends ProcessFunction<String, AssetDetailBO> {
    @Override
    public void processElement(String sentence, Context context, Collector<AssetDetailBO> collector) throws Exception {
        collector.collect(this.map(sentence));
    }

    private AssetDetailBO map(String sentence) {
        String[] strArr = sentence.split(" ");
        AssetDetailBO assetDetail = new AssetDetailBO();
        assetDetail.setTransFirm("CMB");
        assetDetail.setPayCode(strArr[2].matches("-.*") ? "支出" : "收入");
        assetDetail.setTransAmt(strArr[2].replaceAll("-",""));
        assetDetail.setTransSummary(strArr[4] + "-" +strArr[5]);
        assetDetail.setTransDate(strArr[0]);
        assetDetail.setTransStatus("succ");
//        repayPlan.setAssetSide(CastUtil.castString(strArr[0].replaceAll("\"", ""), null));
        return assetDetail;
    }
}
